package samples.d3.color 
{
	import color.HSL;
	import color.RGB;
	import flash.geom.Rectangle;
	import flash.utils.setInterval;
	import samples.BaseSample;
	import shapes.shapes2D.Quad;
	
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Color0 extends BaseSample 
	{
		
		private var hsl:HSL;
		private var quad:Quad;
		private var r:Quad;
		private var g:Quad;
		private var b:Quad;
		public function Color0() 
		{
			
			hsl = new HSL();
			
			quad = new Quad( new Rectangle( 0, 0, 300, 300 ) );
			//quad.strokeColor = 0x808080;
			//quad.strokeWidth = 50;
			addChild( quad );
			quad.x = sw / 2;
			quad.y = sh / 2 - 50;
			
			r = new Quad( new Rectangle( 0, 0, 100, 100 ) );
			g = new Quad( new Rectangle( 0, 0, 100, 100 ) );
			b = new Quad( new Rectangle( 0, 0, 100, 100 ) );
			
			addChild( r );
			addChild( g );
			addChild( b );
			
			r.x = sw/2 - 100
			g.x = sw/2 
			b.x = sw/2 + 100
			r.y = g.y = b.y = sh / 2 + 200;
			
			
			quad.strokeAlpha = r.strokeAlpha = g.strokeAlpha = b.strokeAlpha = 0;
			
			interval =	setInterval( update, 10 );
			
		}
		
		private function update():void 
		{
			
			hsl.hue += 1;
			quad.fillColor = hsl.toHex();
			quad.draw();
			
			r.fillColor = hsl.toRGB().r << 16 ;
			r.draw();
			
			g.fillColor = hsl.toRGB().g << 8;
			g.draw();
			
			b.fillColor = hsl.toRGB().b;
			b.draw();
			
		}
		
		
		
	}

}